//
//  AppDelegate.m
//  UI_豆瓣项目
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 关业达. All rights reserved.
//

#import "AppDelegate.h"
#import "ActivityListViewController.h"
#import "MoveListViewController.h"
#import "CinemaListViewController.h"
#import "UserListViewController.h"
#import "MovieCanViewController.h"

@interface AppDelegate ()<UITabBarControllerDelegate>

@end

@implementation AppDelegate

- (void)dealloc
{
    [_window release];
    [super dealloc];
}



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    // 活动页
    ActivityListViewController *activityVC = [[ActivityListViewController alloc] init];
    UINavigationController *activityNaVC = [[UINavigationController alloc] initWithRootViewController:activityVC];
    UIImage *image1 = [UIImage imageNamed:@"activity.png"];
    activityNaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"活动" image:image1 tag:1001];
    // 设置导航栏图片
    UIImage *image11 = [UIImage imageNamed:@"bg_nav.png"];
    [activityNaVC.navigationBar setBackgroundImage:image11 forBarMetrics:UIBarMetricsDefault];
    
    
    // 电影页
    MoveListViewController *moveVC = [[MoveListViewController alloc] init];
    UINavigationController *moveNaVC = [[UINavigationController alloc] initWithRootViewController:moveVC];
    
//    MovieCanViewController *moveVC = [[MovieCanViewController alloc] init];
//    UINavigationController *moveNaVC = [[UINavigationController alloc] initWithRootViewController:moveVC];
    
    UIImage *image2 = [UIImage imageNamed:@"movie.png"];
    moveNaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"电影" image:image2 tag:1002];
    
    [moveNaVC.navigationBar setBackgroundImage:image11 forBarMetrics:UIBarMetricsDefault];
    
    
    
    // 影院页
    CinemaListViewController *cinemaVC = [[CinemaListViewController alloc] init];
    UINavigationController *cinemaNaVC = [[UINavigationController alloc] initWithRootViewController:cinemaVC];
    UIImage *image3 = [UIImage imageNamed:@"cinema.png"];
    cinemaNaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"影院" image:image3 tag:1003];
    
    [cinemaNaVC.navigationBar setBackgroundImage:image11 forBarMetrics:UIBarMetricsDefault];
    
    
    
    //我的页
    UserListViewController *userVC = [[UserListViewController alloc] init];
    UINavigationController *userNaVC = [[UINavigationController alloc] initWithRootViewController:userVC];
    UIImage *image4 = [UIImage imageNamed:@"user.png"];
    userNaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"用户" image:image4 tag:1003];
    
    [userNaVC.navigationBar setBackgroundImage:image11 forBarMetrics:UIBarMetricsDefault];
    
    
    
    
    UITabBarController *tabBarC = [[UITabBarController alloc] init];
    
    tabBarC.viewControllers = [NSArray arrayWithObjects:activityNaVC, moveNaVC, cinemaNaVC, userNaVC, nil];
    // 指定根视图
    self.window.rootViewController = tabBarC;
    
    tabBarC.delegate = self;
    
    
    
    
    
    
    [userVC release];
    [userNaVC release];
    [cinemaVC release];
    [cinemaNaVC release];
    [moveVC release];
    [moveNaVC release];
    [activityVC release];
    [activityNaVC release];
    [_window release];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
